﻿@using System.Web.Optimization
@using System.Web.UI.WebControls
@using GroceryPriceBook.Infrastructure
@model GroceryPriceBook.Core.ViewModel.PurchaseLogItem

<tr>
	@using (Html.BeginCollectionItem("PurchaseLogItems"))
	{
		@Html.HiddenFor(model => model.Id)
		@Html.HiddenFor(model => model.PurchaseId)
		@Html.HiddenFor(model => model.Product.Id)
		@Html.HiddenFor(model => model.Product.Name)
		@Html.HiddenFor(model => model.Product.Amount)
		@Html.HiddenFor(model => model.Product.CategoryId)
		@Html.HiddenFor(model => model.Product.AmountUnitId)
		@Html.HiddenFor(model => model.Product.Quantity)
		@Html.HiddenFor(model => model.Product.QuantityUnitId)
		@Html.HiddenFor(model => model.Product.ProductManufacturerId)
		if (ViewBag.IsCreate == true)
		{
		}
		else
		{
		}
		<td>
			@Html.DropDownListFor(model => model.ProductId, Model.ProductSelectListItems, "--select one--")
		</td>
		<td>
			<div class="row collapse">
				<div class="large-2 medium-2 small-2 columns">
					<span class="prefix">$</span>
				</div>
				<div class="large-10 medium-10 small-10 columns">
					@Html.TextBoxFor(model => model.Price, "{0:N3}", new { placeholder = "Total $", type = "number", required = "true", style = "width: 80px;" })
				</div>
			</div>
		</td>
		<td>
			@Html.TextBoxFor(model => model.Quantity, new { placeholder = "Quantity", type = "number", value = "1", style = "width: 60px;" })
		</td>
		<td>
			<div class="row collapse">
				<div class="large-2 medium-2 small-2 columns">
					<span class="prefix">$</span>
				</div>
				<div class="large-10 medium-10 small-10 columns">
					@Html.TextBoxFor(model => model.PricePerItem, "{0:N3}", new { @readonly = "true", tabindex = "-1", style = "width: 60px;" })
				</div>
			</div>
		</td>
		<td>
			<div class="row collapse">
				<div class="large-1 medium-2 small-2 columns">
					<span class="prefix">$</span>
				</div>
				<div class="large-6 medium-6 small-6 columns">
					@Html.TextBoxFor(model => model.PricePerAmountUnit, "{0:N3}", new { @readonly = "true", tabindex = "-1" })
				</div>
				<div class="large-5 medium-4 small-4 columns">
					@Html.SpanFor(model => model.Product.ProductAmountUnit.Name, (Model.Product.ProductAmountUnit == null) ? "item" : Model.Product.ProductAmountUnit.Name, "per", "", new { @class = "postfix" })
				</div>
			</div>
		</td>
		<td>
			<div class="row collapse">
				<div class="large-1 medium-2 small-2 columns">
					<span class="prefix">$</span>
				</div>
				<div class="large-6 medium-6 small-6 columns">
					@Html.TextBoxFor(model => model.PricePerQuantityUnit, "{0:N3}", new { @readonly = "true", tabindex = "-1" })
				</div>
				<div class="large-5 medium-4 small-4 columns">
					@Html.SpanFor(model => model.Product.ProductQuantityUnit.Name, (Model.Product.ProductQuantityUnit == null) ? "#" : Model.Product.ProductQuantityUnit.Name, "per", "", new { @class = "postfix" })
				</div>
			</div>
		</td>
		<td>
			@Html.CheckBoxFor(model => model.IsDiscount, new { style = "width: 50px;" })
		</td>
		<td>
			@Html.TextAreaFor(model => model.Note)
		</td>
		<td>
			<a class="button tiny alert" href="#" id="removeItemRow" onclick="$(this).parent().parent().remove();">Remove</a>
		</td>
	}
</tr>
